﻿using Awsc.DataAcquisitionSys.Core.Model.Config;
using Awsc.DataAcquisitionSys.Core.Services.ConfigManagement;
using Microsoft.Extensions.DependencyInjection;

namespace Awsc.DataAcquisitionSys.Core.Services.DataAcquisition.DataCollectors.Sensors
{
    public class SensorFactory
    {


        public static Sensor GetSensor(DataCollectionContext dataCollectionContext, CollectorConfig collectorConfig, SensorConfig sensorConfig)
        {
            var deviceConfigService = dataCollectionContext.Services.GetService<IDeviceConfigService>();
            var deviceConfig = deviceConfigService.GetDeviceConfig();

            switch (sensorConfig.SensorType)
            {
                case "ConventionalSensor":
                    return new ConventionalSensor();
                case "CATSensor":
                    return new CATSensor();
                case "NeutralPointSensor":
                    var neutralPointSensor = new NeutralPointSensor(new AbstractSensorDataCollectionContext() { Service = dataCollectionContext.Services, SensorConfig = sensorConfig });
                    return neutralPointSensor;
                case "PipeSettingDepthSensor":
                    var pipeDepthSensor = new PipeSettingDepthSensor(new AbstractSensorDataCollectionContext() { Service = dataCollectionContext.Services, SensorConfig = sensorConfig });
                    return pipeDepthSensor;
                case "StringWeightSensor":
                    var stringWeightSensor = new StringWeightSensor(new AbstractSensorDataCollectionContext() { Service = dataCollectionContext.Services, SensorConfig = sensorConfig });
                    return stringWeightSensor;
                case "CylinderLiftSensor":
                    var lifttSensor = new CylinderLiftSensor(new AbstractSensorDataCollectionContext() { Service = dataCollectionContext.Services, SensorConfig = sensorConfig });
                    return lifttSensor;
                case "CylinderPressSensor":
                    var pressSensor = new CylinderPressSensor(new AbstractSensorDataCollectionContext() { Service = dataCollectionContext.Services, SensorConfig = sensorConfig });
                    return pressSensor;
                case "WeighSensor":
                    var weightSensor = new PipeSettingDepthSensor(new AbstractSensorDataCollectionContext() { Service = dataCollectionContext.Services, SensorConfig = sensorConfig });
                    return weightSensor;
                default:
                    return new CATSensor();
            }


            throw new NotImplementedException();
        }
    }
}
